<template>
  <div id="layer-manage" :class="{'show-manage':showManage}">
    <div class="title" v-if="!readonly">
      图层管理
      <span class="iconfont icon-bianji" title="编辑图层" @click="addLayerNode"></span>
    </div>
    <layerTree ref="layerTree" :mapId="mapId" @layerClick="layerClick" :readonly="readonly"></layerTree>
    <button class="expand" @click="showManage=!showManage">
      <i class="iconfont icon-zhankai"></i>
    </button>
  </div>
</template>
<script>
import layerTree from "./layerTree";
export default {
  props: {
    readonly: {
      type: Boolean,
      default: true,
      required: false
    },
    mapId: {
      type: String,
      default: "mainMap"
    },
    showTree: {
      type: Boolean,
      default: false
    }
  },
  components: { layerTree },
  data() {
    return {
      showManage: false,
      showEditDialog: false
    };
  },
  methods: {
    addLayerNode() {
      var layerManager = this.$refs.layerTree;
      layerManager.currentData = {
        id: "-1"
      };
      layerManager.addLayerGroupDialog = true;
    },

    layerClick(data) {
      this.$emit("layerClick", data);
    }
  },
  created() {}
};
</script>
<style lang="scss" scoped>
// 地图样式
#layer-manage {
  z-index: 1000;
  position: absolute;
  top: 0%;
  left: 0;
  bottom: 0%;
  min-width: 100px;
  max-width: 300px;
  background-color: rgba(27, 48, 75, 0.6);
  transition: all 0.3s;
  transform: translateX(-100%);
  display: flex;
  flex-direction: column;
  &.show-manage {
    transform: translateX(0%);
    .expand {
      .iconfont {
        transform: rotateY(180deg);
      }
    }
  }
  .title {
    background-color: #1a314b;
    height: 30px;
    line-height: 30px;
    padding: 0px 5px;
    z-index: inherit;
    font-size: 14px;
    color: #11e0ec;
    display: flex;
    flex-wrap: nowrap;
    justify-content: space-between;
    cursor: default;
    .iconfont {
      display: inline;
      cursor: pointer;
    }
  }

  .expand {
    position: absolute;
    top: 0px;
    bottom: 0px;
    background-color: #101f32;
    right: -16px;
    color: #11e0ec;
    border: none;
    z-index: 2;
    cursor: pointer;
    &:focus {
      outline: none;
    }
    .iconfont {
      display: block;
      transition: all 0.3s;
    }
  }

  #layer-tree {
    flex: 1;
    overflow: auto;
  }
}

/deep/ #mainMap_zoom_slider {
  display: none !important;
}
.mapTools {
  position: absolute;
  z-index: 1;
  top: 10px;
  right: 10px;
}
</style>


